package com.atguigu.redis.single;

import com.atguigu.redis.config.spring.code.A;

import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class TestThreadLoacl {
    private static ThreadLocal tl = new ThreadLocal();

    private static volatile AtomicInteger num = new AtomicInteger(3);

    public static void main(String[] args) {
        new Thread(()->{

            try {
                TimeUnit.SECONDS.sleep(5L);
                System.out.println(Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            num.decrementAndGet();
        },"A").start();
        new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(1L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
            num.decrementAndGet();
        },"B").start();
        new Thread(()->{
            try {
                TimeUnit.SECONDS.sleep(4L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
            num.decrementAndGet();
        },"C").start();
        while (num.get()!=0){

        }
        tl.remove();
        System.out.println("执行完毕");

    }
}
